﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.IO;
using System.Xml;

namespace Util
{
    public class XMLOption
    {
        FileStream fs;
        XmlDataDocument xmlDoc;
        XmlNodeList nodeList;

        public XMLOption()
        {
            xmlDoc = new XmlDataDocument();
        }

        public XMLOption(String filePath)
        {
            try
            {
                xmlDoc = new XmlDataDocument();
                fs = new FileStream(filePath, FileMode.Open, FileAccess.Read);
                xmlDoc.Load(fs);
            }
            catch (Exception ex)
            {
                Util.Log.LogError(ex.StackTrace);
            }
        }

        ~XMLOption()
        {
            try
            {
                this.Close();
            }
            catch (Exception ex)
            {
                Util.Log.LogError(ex.StackTrace);
            }
        }

        public void Close()
        {
            if(fs != null)
                fs.Close();
        }

        public XmlNodeList SelectNodes(String name)
        {
            return xmlDoc.SelectNodes(name);
        }
    }
}